package com.ls.blog.utils;

import com.ls.blog.dto.UserDetailsIml;
import org.springframework.security.core.context.SecurityContextHolder;

public class UserUtils {


    /**
     * 获得当前登录用户
     * @return
     */
    public static UserDetailsIml getCurrentUser(){
        UserDetailsIml principal = null;
        try{
            principal = (UserDetailsIml) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        }catch (Exception e){
            e.printStackTrace();
        }
        return principal;
    }
}
